package org.gruposp2p.proyectokarma.gwt.client.event;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import org.gruposp2p.proyectokarma.gwt.client.domain.Document;
import org.gruposp2p.proyectokarma.gwt.client.domain.Vote;

import java.util.List;

public class VoteEvent extends GwtEvent {
	
    private static final GwtEvent.Type TYPE = new GwtEvent.Type();

    public List<Vote> votes;
    public int eventType;
    public static final int TYPE_EDITION  = 0;
    public static final int TYPE_DELETION = 1;
    public static final int TYPE_ADDITION = 2;
    public static final int TYPE_FETCHED  = 4;

    public static GwtEvent.Type getType() { return TYPE;}

    @Override
    public Type getAssociatedType() { return TYPE;}

    @Override
    protected void dispatch(EventHandler handler) {
    	((VoteEvent.Handler)handler).onVoteChanged(this);
    }

    public VoteEvent (List<Vote> votes, int eventType) {
        this.votes = votes;
        this.eventType = eventType;
    }
    
    /**
     * Implemented by handlers of this type of event.
     */
    public interface Handler extends EventHandler {
    	void onVoteChanged(VoteEvent event);
    }

}